﻿@page
@using FDSimpleModelGenerator.Models
@using FDSimpleModelGenerator.Common.Mvc
@model IndexModel
@{
    ViewData["Title"] = "遊龍数据模型在线生成器";
    var param = new GenerateModel
    {
        Database = "LanGuo",
        Namespace = "FDSimpleModelGenerator.Demo.SqlServer",
        UserId = "sa",
        Password = "DX.net123!@#",
        ServerName = "192.168.50.79",
        TableName = "romOrder",
        TemplateName = "Class.fdtpl"
    };
    //var param = new GenerateModel
    //{
    //    Database = "demo",
    //    Namespace = "FDSimpleModelGenerator.Demo",
    //    UserId = "root",
    //    Password = "1234",
    //    ServerName = "localhost",
    //    TableName = "user"
    //};
}
@section Styles{
    <link href="~/css/index.min.css" rel="stylesheet" />
    <style>
        .main-config{
            border-radius: 10px;
        }
        #result {
            text-align: left;
            margin-bottom: 80px;
        }

            #result .item {
                margin-top: 20px;
            }

                #result .item .oper {
                    background: #6ea0de;
                    color: #fff;
                    padding: 5px;
                }

                    #result .item .oper a {
                        /*cursor: pointer;*/
                        margin-left: 10px;
                        color: #ffffff;
                        text-decoration: none;
                    }

                        #result .item .oper a:hover {
                            color: #ff8c00;
                        }

                #result .item .content {
                    background: #f8f9fa;
                    font-size: 14px;
                    font-family: arial;
                    padding-top: 15px;
                    padding-bottom: 15px;
                    padding-left: 5px;
                }

        .popover-body {
            color: #ff0000 !important;
        }
    </style>
}
@Html.AntiForgeryToken()
<div class="text-center">
    @*<h3 class="display-4">遊龍模型生成器</h3>*@
    <div class="main-config row bg-1 p-3">
        <div class="db-config col-md-5">
            <div class="row">
                <label class="col-md-3 text-light mt-2 text-right">库类型</label>
                <select name="DbType" class="form-control col-md-9" placeholder="请选择模型模板名称">
                    @foreach (var dbType in Model.DatabaseTypes)
                    {
                        <option value="@dbType.Value">@dbType.Name</option>
                    }
                </select>
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">服务器</label>
                <input class="col-md-9 form-control" type="text" id="txtServer" name="ServerName" placeholder="请输入服务器" value="@param.ServerName" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">端口</label>
                <input class="col-md-9 form-control" type="text" id="txtPort" name="Port" placeholder="请输入服务器端口" value="@param.Port" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">数据库</label>
                <input class="col-md-9 form-control" type="text" id="txtDatabase" name="Database" placeholder="请输入数据库" value="@param.Database" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">用户名</label>
                <input class="col-md-9 form-control" type="text" id="txtUserId" name="UserId" placeholder="请输入用户名" value="@param.UserId" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">密码</label>
                <input class="col-md-9 form-control" type="password" id="txtPassword" name="Password" placeholder="请输入密码" value="@param.Password" />
            </div>
        </div>
        <div class="model-config col-md-7">
            <div class="row">
                <label class="col-md-3 text-light mt-2 text-right">命名空间</label>
                <input class="col-md-9 form-control" type="text" id="txtNamespace" name="Namespace" placeholder="请输入命名空间" value="@param.Namespace" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">表名</label>
                <input class="col-md-9 form-control" type="text" id="txtTableName" name="TableName" placeholder="请输入表名，“,”分隔" value="@param.TableName" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">模型模板</label>
                <select name="TemplateFileName" class="form-control col-md-9" placeholder="请选择模型模板名称">
                    @foreach (var template in Model.Templates)
                    {
                        <option value="@template.Value" data-type="@template.Code">@template.Name</option>
                    }
                </select>
                <input type="hidden" name="TemplateName" />
                <input type="hidden" name="LanguageDataType" />
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">属性首字母</label>
                <select name="FirstCharFormat" class="form-control col-md-9" placeholder="请选择属性首字母格式">
                    <option value="1">大写</option>
                    <option value="0">小写</option>
                </select>
            </div>
            <div class="row mt-1">
                <label class="col-md-3 text-light mt-2 text-right">缓存的配置</label>
                <select name="CachedKey" class="form-control col-md-9" placeholder="选择缓存的配置"></select>
            </div>
            @*<div class="row">&nbsp;</div>*@
            <div class="row mt-1">
                <button class="col-md-3 offset-9 form-control bg-warning mr-1 text-light" id="btnGenerate" data-container="body" data-toggle="popover" data-placement="bottom" data-content="">生成</button>
            </div>
        </div>
    </div>
    <div class="row">
        <div id="result" class="col-md-10">
            @*<div class="item">
                    <div class="oper"><a href="#">a.cs</a></div>
                </div>
                <div class="item">
                    <div class="oper"><a onclick="copy()" href="#">Copy</a><a href="#">Download</a></div>
                    <div class="content">
                    </div>
                </div>*@
        </div>
    </div>
</div>
@*@await Component.InvokeAsync("Hello")*@

@*<button id="btnShowUpload" class="d-none">Upload</button>*@
@*@await Component.InvokeAsync("Upload")*@

@section Scripts
{
    <script src="~/lib/clipboard/clipboard.min.js"></script>
    <script src="~/js/jquery.extend.js"></script>
    <script src="~/lib/bootstrap/typeahead/bootstrap3-typeahead.min.js"></script>
    @Html.InclueScript("~/js/createmodel.js")
    <script>

    </script>
}

